/* ========================================================================= */
/* ------------------------------------------------------------------------- */
/*!
  \file			ETU_CreateIt.h
  \date			september 2011
  \author		TNick

  \brief		Contains the definition for ETU_CreateIt class


  Copyright (c) 2011, Nicu Tofan
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 * Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
 * Neither the name of the copyright holder nor the
   names of its contributors may be used to endorse or promote products
   derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND
 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL NICU TOFAN BE LIABLE FOR ANY
 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
#ifndef __ETU_CREATEIT_INC__
#define __ETU_CREATEIT_INC__
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */

class		QGraphicsItem;
class		ETSheetView;
class		ETSheet;
class		ETUndoHead;



#include	<sheet/ETUndoElem.h>

/*  INCLUDES    ============================================================ */
//
//
//
//
/*  CLASS    --------------------------------------------------------------- */

/// undo/redo action for creating / deleting an item
/**
*	This class uses the mirroring feature of the ETUndoElem class to make
*	itself usable for both creating and deleting items (classes that inherit
*	from QGraphicsItem).
*	The class uses either ETUndoElem::CREATE_ITEM or ETUndoElem::DELETE_ITEM
*
*/
class ETU_CreateIt : public ETUndoElem		{

	//
	//
	//
	//
	/*  DEFINITIONS    ----------------------------------------------------- */


	/*  DEFINITIONS    ===================================================== */
	//
	//
	//
	//
	/*  DATA    ------------------------------------------------------------ */

private:

	/// the item that must be created / deleted
	QGraphicsItem *		assoc_it;
	/// associated sheet where actions are performed
	ETSheet *			sheet;

	/*  DATA    ============================================================ */
	//
	//
	//
	//
	/*  FUNCTIONS    ------------------------------------------------------- */

public:

	/// constructor
	/**
   */
	ETU_CreateIt			(
		ETUndoElem::Type	el_ty,	/**< must be either
	ETUndoElem::CREATE_ITEM or ETUndoElem::DELETE_ITEM */
		QGraphicsItem *		it_to_handle	/**< the item that must be handled;
	if the item expires in the undo state the instance is deleted. */
		);


	/// destructor
	/**
	*	May destroy the item it hosts on certain conditions.
	*/
	virtual					~ETU_CreateIt		( void );



	/// tell if the item was created as a result of a create event or a delete
	inline bool				fromDelete			(void)
	{ return isMirrored(); }





	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
	/** @name Required to be implemented by the ETUndoElem    */
	//@{
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
public:


	/// perform the undo action
	void					performUndo	( void );


	/// perform the redo action
	void					performRedo	( void );


	//@}
	/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */




	/*  FUNCTIONS    ======================================================= */
	//
	//
	//
	//

};	/*	class ETU_CreateIt	*/

/*  CLASS    =============================================================== */
//
//
//
//
#endif // __ETU_CREATEIT_INC__
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
